﻿@model FinalProject.Web.ViewModels.HomeViewModel
<table id="newspaper-a" summary="2007 Major IT Companies' Profit">
    <thead>
        <tr>
            <th scope="col">
                First Name
            </th>
            <th scope="col">
                Last Name
            </th>
            <th scope="col">
                Phone
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var client in Model.Clients)
        {
            <tr>
                <td>@client.PersonName.FirstName
                </td>
                <td>@client.PersonName.LastName
                </td>
                <td>@client.PersonName.MiddleName
                </td>
            </tr>
        }
    </tbody>
</table>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<p>
    <label title="search">
        Search:
    </label>
    <input type="text" id="searchBox" />
</p>

<script type="text/javascript">
    $("#searchBox").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: '@Url.Action("FindClients", "Home")',

                data: { search: request.term },
                dataType: 'json',
                type: 'POST',
                success: function (data) {
                    response(data)
                }
            })
        },
        minLength: 1
    });
</script>
